package com.tracesystem.commons;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.List;
@ApiModel("结果返回")
public class Result<T> {
    @ApiModelProperty("描述信息")
    private String msg;
    @ApiModelProperty("状态码")
    private Integer code;
    @ApiModelProperty("返回数据")
    private T data;

    public static <D> Result<D> getInstance(Class<D> type) {
        Result<D> dResult = new Result<D>();
        dResult.code = 200;
        dResult.msg = "成功";
        return dResult;
    }

    public static Result<?> getInstance() {
        Result<?> dResult = new Result<>();
        dResult.data = null;
        dResult.code = 200;
        dResult.msg = "成功";
        return dResult;
    }

    public static <D> Result<List<D>> getInstanceList(Class<D> type) {
        Result<List<D>> listResult = new Result<>();
        listResult.data = null;
        listResult.code = 200;
        listResult.msg = "成功";
        return listResult;

    }

    public String getMsg() {
        return msg;
    }

    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public Result setCode(Integer code) {
        this.code = code;
        return this;
    }

    public T getData() {
        return data;
    }

    public Result setData(T data) {
        this.data = data;
        return this;
    }
}
